<template>
    <div>
<table>
    <tbody>
        <tr>
            <td>编号</td>
            <td>
                <input type="text" name="" v-model="date.number" id="">
            </td>
        </tr>
        <tr>
            <td>名称</td>
            <td>
                <input type="text" name="" v-model="date.name" id="">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" value="保存" @click="add">
            </td>
            
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const router=useRouter()
const add=()=>{
    if(date.value.number==""){
alert('编号不能为空')
return
    }
    if(date.value.name==""){
alert('名称不能为空')
return
    }
    axios.post('https://localhost:7094/api/House/Add',date.value).then(res=>{
if(res.data>0){
    alert('成功')
    router.push({path:"/show"})
}else{
    alert('失败')
}

    })
}
// const login=()=>{
//     axios.get('').then(res=>{
        
//     })
// }
const date=ref({
    "hid": 0,
  "number": "",
  "name": ""
})
</script>

<style scoped>

</style>